Component({
  properties: {
    currentPath: {
      type: String,
      value: ''
    }
  },
  data: {
    list: [
      {
        pagePath: "pages/index/index",
        text: "角色",
        iconPath: "../../static/tab1-inactive.png",
        selectedIconPath: "../../static/tab1-active.png"
      },
      {
        pagePath: "pages/memory/memory",
        text: "记忆",
        iconPath: "../../static/tab2-inactive.png",
        selectedIconPath: "../../static/tab2-active.png"
      },
      {
        pagePath: "pages/device/device",
        text: "设备",
        iconPath: "../../static/tab3-inactive.png",
        selectedIconPath: "../../static/tab3-active.png"
      }
    ]
  },
  methods: {
    onTap(e) {
      const pagePath = '/' + e.currentTarget.dataset.pagePath;
      if (this.data.currentPath !== pagePath) {
        console.log(pagePath);
        console.log(this.data.currentPath);
        wx.switchTab({
          url: pagePath,
          success: function (res) {
            console.log(res);
          },
          fail: function (res) {
            console.log(res);
            console.log(pagePath)
            console.log('fail');
          }
        });
      }
      console.log('tap');
    }
  }
});
